package com.kingyea.mobilepolice.roleapipermission.service.impl;

import com.kingyea.mobilepolice.roleapipermission.bean.RoleApiPermission;
import com.kingyea.mobilepolice.roleapipermission.dao.RoleApiPermissionMapper;
import com.kingyea.mobilepolice.roleapipermission.service.RoleApiPermissionService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author hx
 * @version v1.0.0
 * @description RoleApiPermission 实现类
 * @date Created in 2018-05-15 20:25:07
 */
@Service
@Transactional
public class RoleApiPermissionServiceImpl implements RoleApiPermissionService {

    private static final Logger LOGGER = LoggerFactory.getLogger(RoleApiPermissionServiceImpl.class);

    @Resource
    private RoleApiPermissionMapper roleApiPermissionMapper;

    /**
     * 通过ID查找对象
     *
     * @param roleId
     * @return
     */
    @Override
    public RoleApiPermission getById(Integer roleId) throws Exception {
        return this.roleApiPermissionMapper.getById(roleId);
    }

    /**
     * 列表
     *
     * @param
     * @return
     */
    @Override
    public List<RoleApiPermission> search(RoleApiPermission roleApiPermission) throws Exception {
        List<RoleApiPermission> list = roleApiPermissionMapper.search(roleApiPermission);
        return list;
    }

    /**
     * 删除
     *
     * @param roleId
     * @return
     */
    @Override
    public int deleteById(Integer roleId) throws Exception {
        roleApiPermissionMapper.deleteById(roleId);
        return 1;
    }

    /**
     * 保存
     *
     * @param roleApiPermission
     * @return
     */
    @Override
    public RoleApiPermission save(RoleApiPermission roleApiPermission) throws Exception {
        try {
            roleApiPermissionMapper.save(roleApiPermission);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return roleApiPermission;
    }

    /**
     * 更新
     *
     * @param roleApiPermission
     * @return
     */
    @Override
    public RoleApiPermission update(RoleApiPermission roleApiPermission) throws Exception {
        try {
            roleApiPermissionMapper.update(roleApiPermission);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return roleApiPermission;
    }

    @Override
    public Object searchByRole(RoleApiPermission roleApiPermission) throws Exception {
        return roleApiPermissionMapper.searchByRole(roleApiPermission);
    }


}
